package com.itheima.stock.mapper;

import com.itheima.stock.common.domain.InnerMarketDomain;
import com.itheima.stock.common.domain.OutMarketDomain;
import com.itheima.stock.pojo.StockMarketIndexInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.joda.time.DateTime;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
* @author HearTheSong
* @description 针对表【stock_market_index_info(股票大盘数据详情表)】的数据库操作Mapper
* @createDate 2022-03-13 17:42:28
* @Entity com.itheima.stock.pojo.StockMarketIndexInfo
*/
@Mapper
public interface StockMarketIndexInfoMapper {

    int deleteByPrimaryKey(Long id);

    int insert(StockMarketIndexInfo record);

    int insertSelective(StockMarketIndexInfo record);

    StockMarketIndexInfo selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(StockMarketIndexInfo record);

    int updateByPrimaryKey(StockMarketIndexInfo record);

    /**
     * 根据注定的id集合和日期查询大盘数据
     * @param marketId 大盘id集合
     * @param lastDate 对应日期
     * @return
     */
    List<InnerMarketDomain> selectByIdsAndDate(@Param("marketId") List<String> marketId, @Param("lastDate") Date lastDate);
    /**
     * 功能描述：统计国内A股大盘T日和T-1日成交量对比功能（成交量为沪市和深市成交量之和）
     *   map结构示例：
     *      {
     *         "volList": [{"count": 3926392,"time": "202112310930"},......],
     *       "yesVolList":[{"count": 3926392,"time": "202112310930"},......]
     *      }
     *      codeList:A股id
     *      openDate:开盘时间
     *      lastDate:当前最新时间
     * @return
     */
    List<Map> stockVolCountByTime(@Param("codeList") List<String> innerCode,@Param("openDate") Date openDate,@Param("lastDate") Date lastDate);
    /*
        向大盘中批量插入通过接口获取的数据
     */
    void insertBatch(@Param("list") ArrayList<StockMarketIndexInfo> list);
    /*
        功能描述：外盘指数行情数据查询，根据时间和大盘点数降序排序取前4
        服务路径：/api/quot/external/index
        服务方法：GET
        请求参数：无
    */
    List<OutMarketDomain> getOutMarketAllInfo(@Param("ids") List<String> outerIds,@Param("date") Date date);
}
